/********************************************************************
*Copyright (C) 2011,China CQU EasyBoard Team.
*All rights reserved.
*
*File Name:connectsocket.h
*File ID  :
*Summary  :this file declares the communication socket with server or
*other client.
*ConnectSocekt is a subclass of the QTcpSocket.
*ConnectSocket implements all the communication function
*
*Version  :1.0.0
*Author   :YaoBoYuan
*Date     :2011-5-28
********************************************************************/

#ifndef CONNECTSOCKET_H
#define CONNECTSOCKET_H

#include <QObject>
#include <QTcpSocket>

#include "Protocol/msgheader.h"

class ConnectSocket : public QTcpSocket
{
    Q_OBJECT
public:
    explicit ConnectSocket(QObject *parent = 0);

signals:
    void newData(MSGHeader header,QByteArray data);

public slots:
    void processReadyRead();
    void processBytesWritten(qint64 bytes);
    void processConnected();
    void processDisconnect();

    void processReadChannelFinished();
    void processAboutToClose();

    void sendPackage(QByteArray package);

public:

private:
    MSGHeader m_header;
    QByteArray m_data;

};

#endif // CONNECTSOCKET_H
